#include <pspsdk.h>
#include "ctrl.h"

/*
 * Imports from library: SysMemForKernel
 */
extern int SysMemForKernel_2CFF6F90 ();

/*
 * Imports from library: sceSuspendForKernel
 */
extern void sceKernelPowerTick (int arg1);

/*
 * Imports from library: sceSysEventForKernel
 */
extern void sceKernelRegisterSysEventHandler (int arg1);
extern void sceKernelUnregisterSysEventHandler (int arg1);

/*
 * Imports from library: KDebugForKernel
 */
extern int KDebugForKernel_BB74144A ();

/*
 * Imports from library: InterruptManagerForKernel
 */
extern int sceKernelCpuSuspendIntr ();
extern void sceKernelCpuResumeIntr (int arg1);
extern void InterruptManagerForKernel_668A0FF9 (int arg1, int arg2);
extern void InterruptManagerForKernel_CFFA1857 (int arg1, int arg2, int arg3, int arg4);
extern void sceKernelReleaseSubIntrHandler (int arg1, int arg2);
extern void sceKernelEnableSubIntr (int arg1, int arg2);

/*
 * Imports from library: SysclibForKernel
 */
extern void memset (int arg1, int arg2, int arg3);

/*
 * Imports from library: ThreadManForKernel
 */
extern void sceKernelSetEventFlag (int arg1, int arg2);
extern int sceKernelGetSystemTimeLow ();
extern int sceKernelWaitEventFlag (int arg1, int arg2, int arg3, int arg4, int arg5);
extern int sceKernelCreateEventFlag (int arg1, int arg2, int arg3, int arg4);
extern void sceKernelSetAlarm (int arg1, int arg2, int arg3);
extern void sceKernelClearEventFlag (int arg1, int arg2);
extern void sceKernelDeleteEventFlag (int arg1);

/*
 * Imports from library: SysTimerForKernel
 */
extern void SysTimerForKernel_1013EB8B (int arg1);
extern int SysTimerForKernel_1E99FA82 ();
extern void SysTimerForKernel_62AB11D2 (int arg1);
extern void SysTimerForKernel_D9A211BC (int arg1);
extern void SysTimerForKernel_E0331FB2 (int arg1, int arg2, int arg3);
extern void SysTimerForKernel_F5A719D1 (int arg1, int arg2, int arg3, int arg4);

/*
 * Imports from library: sceDisplay_driver
 */
extern void sceDisplay_driver_63CA4B93 ();

/*
 * Imports from library: sceSyscon_driver
 */
extern int sceSysconCmdExecAsync (int arg1, int arg2, int arg3, int arg4);
extern void sceSyscon_driver_90D2024A (int arg1);

/**
 * Subroutine at address 0x00000000
 */
void sceCtrl_driver_45F1294D ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  ((int *) sp)[1] = s1;
  memset (0x00001F00, 0x00000000, 0x00000AA8);
  *((int *) 0x00001F14) = 0x00000001;
  *((char *) 0x00002931) = 0xFFFFFF80;
  *((char *) 0x00002930) = 0xFFFFFF80;
  *((int *) 0x00001F18) = 0xFFFFFFFF;
  var5 = sceKernelCreateEventFlag ("SceCtrl", 0x00000001, 0x00000000, 0x00000000);
  *((int *) 0x00001F04) = var5;
  var8 = SysTimerForKernel_1E99FA82 ();
  var9 = var8;
  if (!(var8 < 0))
  {
    *((int *) 0x00001F00) = var8;
    SysTimerForKernel_E0331FB2 (var8, 0x00000001, 0x00000030);
    *((char *) 0x00001F0F) = 0xFFFFFFFF;
    sceKernelRegisterSysEventHandler (0x00001EC0);
    sceSyscon_driver_90D2024A (0x00000000);
    *((int *) 0x00002964) = 0x00000081;
    *((int *) 0x00002944) = 0x0002F3F9;
    *((int *) 0x0000294C) = 0x01FFF3F9;
    *((int *) 0x00002950) = 0x39FFF3F9;
    *((int *) 0x00002954) = 0x38F1F3F9;
    *((int *) 0x00002958) = 0x390E0000;
    *((int *) 0x00002960) = 0x00000081;
    *((int *) 0x00002948) = 0x00000000;
    *((int *) 0x0000295C) = 0x00000000;
    InterruptManagerForKernel_CFFA1857 (0x0000001E, 0x00000013, 0x00000330, 0x00000000);
    sceKernelEnableSubIntr (0x0000001E, 0x00000013);
    var22 = KDebugForKernel_BB74144A ();
    if (var22 == 0x00000000)
    {

    label26:
      var9 = 0x00000000;
    }
    else
    {
      var23 = ((int *) var22)[0];
      if (!(var23 == 0x00000030))
        goto label26;
      var27 = ((int *) var22)[11];
      var30 var31 = (*var27) (0x00001E98);
      var9 = 0x00000000;
    }
  }
  ra = ((int *) sp)[3];
  var24 = ((int *) sp)[2];
  var25 = ((int *) sp)[1];
  var26 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000160
 */
void sceCtrl_driver_A6CF75FE ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  sceKernelUnregisterSysEventHandler (0x00001EC0);
  sceSyscon_driver_90D2024A (0x00000001);
  sceDisplay_driver_63CA4B93 ();
  var7 = *((int *) 0x00001F00);
  *((int *) 0x00001F00) = 0xFFFFFFFF;
  if (!(var7 < 0))
  {
    SysTimerForKernel_62AB11D2 (var7);
    SysTimerForKernel_1013EB8B (var7);
  }
  sceKernelReleaseSubIntrHandler (0x0000001E, 0x00000013);
  var14 = *((int *) 0x00001F04);
  sceKernelDeleteEventFlag (var14);
  var17 = *((int *) 0x00001F10);
  if (!(var17 == 0x00000000))
  {
    while (1) {
      sceDisplay_driver_63CA4B93 ();
      var20 = *((int *) 0x00001F10);
      if (var20 != 0x00000000)
        continue;
      break;
    }
  }
  ra = ((int *) sp)[2];
  var21 = ((int *) sp)[1];
  var22 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000200
 */
void sub_00200 (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  if (arg1 == 0x00000402)
  {
    var21 = *((int *) 0x00001F10);
    if (var21 == 0x00000000)
    {

    label29:
      ra = ((int *) sp)[2];
    }
    else
    {
      var22 = *((int *) 0x00001F18);
      var1 = 0x80000021;
      if (var22 == 0x00000000)
      {

      label28:
        goto label29;
      }
      else
      {
        ra = ((int *) sp)[2];
      }
    }
  }
  else
  {
    if (((arg1 < 0x00000403)) == 0x00000000)
    {
      if (arg1 == 0x0000400C)
      {
        var15 = *((int *) 0x00001F08);
        if (var15 != 0x00000000)
        {
          var18 = *((int *) 0x00001F00);
          SysTimerForKernel_62AB11D2 (var18);
        }
        else
        {
          InterruptManagerForKernel_668A0FF9 (0x0000001E, 0x00000013);
        }
      }
      else
      {
        if (!(arg1 != 0x0001000C))
        {
          var5 = *((int *) 0x00001F08);
          *((char *) 0x00001F0F) = 0xFFFFFFFF;
          if (var5 != 0x00000000)
          {
            var8 = *((int *) 0x00001F00);
            SysTimerForKernel_D9A211BC (var8);
            var11 = *((int *) 0x00001F08);
            var12 = *((int *) 0x00001F00);
            SysTimerForKernel_F5A719D1 (var12, var11, 0x000003F0, 0x00000000);
          }
          else
          {
            sceKernelEnableSubIntr (0x0000001E, 0x00000013);
          }
          *((int *) 0x00001F18) = 0xFFFFFFFF;
          goto label28;
        }
      }
    }
    else
    {
      if (arg1 == 0x00000400)
      {
        var4 = *((int *) 0x00001F1C);
        *((int *) 0x00001F18) = var4;
      }
      goto label28;
    }
    goto label29;
  }
  var2 = ((int *) sp)[1];
  var3 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000330
 */
void sub_00330 ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  var3 = sceKernelCpuSuspendIntr ();
  var4 = *((int *) 0x00001F08);
  if (!(var4 != 0x00000000))
  {
    var5 = *((unsigned char *) 0x00001F10);
    if (var5 != 0x00000000)
    {

    label15:
      sceKernelSetAlarm (0x000002BC, 0x00001690, 0x00000000);
    }
    else
    {
      var6 = *((int *) 0x00001F14);
      if (!(var6 != 0x00000000))
        goto label15;
      var13 = *((unsigned short *) 0x00001F0C);
      *((char *) 0x00001F10) = 0x00000001;
      var14 = 0x00000007;
      if (!(var13 == 0x00000000))
      {
        var14 = 0x00000008;
      }
      *((char *) 0x00001F2C) = var14;
      *((char *) 0x00001F2D) = 0x00000002;
      var17 = sceSysconCmdExecAsync (0x00001F20, 0x00000001, 0x000004B0, 0x00000000);
      if (var17 < 0)
      {
        *((char *) 0x00001F10) = 0x00000000;
      }
      else
      {
      }
    }
  }
  sceKernelCpuResumeIntr (var3);
  ra = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000003F0
 */
void sub_003F0 ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  var3 = sceKernelCpuSuspendIntr ();
  var4 = *((int *) 0x00001F08);
  if (!(var4 == 0x00000000))
  {
    var5 = *((unsigned char *) 0x00001F10);
    if (var5 != 0x00000000)
    {

    label15:
      sceKernelSetAlarm (0x000002BC, 0x00001690, 0x00000000);
    }
    else
    {
      var6 = *((int *) 0x00001F14);
      if (!(var6 != 0x00000000))
        goto label15;
      var13 = *((unsigned short *) 0x00001F0C);
      *((char *) 0x00001F10) = 0x00000001;
      var14 = 0x00000007;
      if (!(var13 == 0x00000000))
      {
        var14 = 0x00000008;
      }
      *((char *) 0x00001F2C) = var14;
      *((char *) 0x00001F2D) = 0x00000002;
      var17 = sceSysconCmdExecAsync (0x00001F20, 0x00000001, 0x000004B0, 0x00000000);
      if (var17 < 0)
      {
        *((char *) 0x00001F10) = 0x00000000;
      }
      else
      {
      }
    }
  }
  sceKernelCpuResumeIntr (var3);
  ra = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000004B0
 */
void sub_004B0 (int arg1)
{
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[6] = s6;
  var1 = arg1;
  ((int *) sp)[1] = s1;
  ((int *) sp)[7] = ra;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[0] = s0;
  var2 = *((int *) 0x00001F18);
  *((char *) 0x00001F10) = 0x00000000;
  if (!(var2 <= 0))
  {
    var2 = var2 + 0xFFFFFFFF;
    *((int *) 0x00001F18) = var2;
  }
  if (var2 == 0x00000000)
  {
    var67 = sceKernelCpuSuspendIntr ();
    var68 = *((int *) 0x00001F18);
    if (var68 != 0x00000000)
    {
      var70 = *((int *) 0x00002920);
    }
    else
    {
      var69 = *((int *) 0x00002920);
      var70 = var69 & 0xFFFF0C06;
    }
    var71 = *((unsigned char *) 0x00002930);
    var72 = *((unsigned char *) 0x00002931);
    sub_00880 (var70, var71, var72);
    var75 = *((int *) 0x00001F04);
    sceKernelSetEventFlag (var75, 0x00000001);
    sceKernelCpuResumeIntr (var67);
    ra = ((int *) sp)[7];
  }
  else
  {
    var3 = ((unsigned char *) var1)[12];
    var4 = *((int *) 0x00002920);
    if (((((var3 ^ 0x00000002) < 0x00000001)) | (((var3 ^ 0x00000006) < 0x00000001))) == 0x00000000)
    {
      var7 = var4;
      if (!((((var3 + 0xFFFFFFF9) < 0x00000002)) == 0x00000000))
      {
        var61 = ((unsigned char *) var1)[34];
        var62 = ((unsigned char *) var1)[33];
        var63 = ((unsigned char *) var1)[32];
        var64 = ((unsigned char *) var1)[31];
        var7 = ((((((((var61 & 0x00000003) << 0x0000001C) | ((var62 & 0x000000BF) << 0x00000014)) | ((var63 & 0x000000F0) << 0x0000000C)) | ((var64 & 0x000000F0) << 0x00000008)) | ((var63 & 0x00000006) << 0x00000007)) | ((var64 & 0x0000000F) << 0x00000004)) | (var63 & 0x00000009)) ^ 0x20F7F3F9;
      }
    }
    else
    {
      var5 = ((unsigned char *) var1)[32];
      var6 = ((unsigned char *) var1)[31];
      var7 = (((((((var5 & 0x000000F0) << 0x0000000C) | ((var6 & 0x000000F0) << 0x00000008)) | ((var5 & 0x00000006) << 0x00000007)) | ((var6 & 0x0000000F) << 0x00000004)) | (var5 & 0x00000009)) ^ 0x0007F3F9) | ((var4 & 0xFFF00000) | (0x00000000 & 0x000FFFFF));
    }
    *((int *) 0x00002920) = var7;
    if (var3 == 0x00000003)
    {
      var8 = ((unsigned char *) var1)[32];
      var9 = ((unsigned char *) var1)[31];
    }
    else
    {
      if (var3 == 0x00000006)
      {
        var8 = ((unsigned char *) var1)[34];
        var9 = ((unsigned char *) var1)[33];
      }
      else
      {
        if (var3 == 0x00000008)
        {
          var8 = ((unsigned char *) var1)[36];
          var9 = ((unsigned char *) var1)[35];
        }
        else
        {
          var8 = *((unsigned char *) 0x00002931);
          var9 = *((unsigned char *) 0x00002930);
        }
      }
    }
    *((char *) 0x00002930) = var9;
    *((char *) 0x00002931) = var8;
    sub_00880 (var7, var9, var8);
    if ((var7 & 0x00020000) == 0x00000000)
    {
      var12 = *((int *) 0x00002950);
      var13 = *((int *) 0x00002954);
      var14 = *((int *) 0x00002960);
    }
    else
    {
      var12 = *((int *) 0x00002958);
      var13 = *((int *) 0x0000295C);
      var14 = *((int *) 0x00002964);
    }
    var15 = *((int *) 0x0000294C);
    var16 = (((var7 ^ var4) & var12) | (var7 & var13)) & var15;
    if (var16 != 0x00000000)
    {

    label40:
      sceKernelPowerTick (0x00000000);
    }
    else
    {
      var17 = *((unsigned char *) 0x00001F0C);
      var18 = var9 + 0xFFFFFF80;
      if (!(var17 == 0x00000000))
      {
        var19 = var8 + 0xFFFFFF80;
        var20 = (MAX (var18, (0x00000000 - var18))) & 0x000000FF;
        var21 = (MAX (var19, (0x00000000 - var19))) & 0x000000FF;
        if ((((!((var20 ^ 0x0000007F)) ? 0x00000080 : var20) < var14)) == 0x00000000)
        {

        label38:
          var16 = 0x00000001;
        }
        else
        {
          if (!((((!((var21 ^ 0x0000007F)) ? 0x00000080 : var21) < var14)) != 0x00000000))
            goto label38;
        }
      }
      if (!(var16 == 0x00000000))
        goto label40;
    }
    var24 = gp;
    var25 = *((int *) 0x0000293C);
    var26 = *((int *) 0x00002924);
    var27 = 0x00001F00;
    var28 = var7 | var25;
    *((int *) 0x00002924) = var28;
    var29 = 0x00000003;
    while (1) {
      var30 = ((int *) var27)[666];
      var31 = (var28 ^ var26) & var30;
      if (var31 == 0x00000000)
      {
        var29 = var29 + 0xFFFFFFFF;
      }
      else
      {
        var32 = ((int *) var27)[667];
        if (var32 != 0x00000000)
        {
          var53 = ((int *) var27)[668];
          var54 = gp;
          gp = var53;
          var55 = ((int *) var27)[667];
          var56 = ((int *) var27)[669];
          var59 var60 = (*var55) (var28, var26, var56, 0x00001F00, var31, var30, var32, var55);
          var29 = var29 + 0xFFFFFFFF;
        }
        else
        {
          var29 = var29 + 0xFFFFFFFF;
        }
      }
      var27 = var27 + 0x00000010;
      if (var29 >= 0)
        continue;
      break;
    }
    var33 = gp;
    gp = var24;
    var34 = *((unsigned short *) 0x00001F0C);
    var35 = *((unsigned char *) 0x00001F0E);
    var36 = *((unsigned char *) 0x00001F0F);
    var37 = (0x00000000 < var34);
    var38 = (var35) ? (var37 | 0x00000002) : var37;
    if (var38 == var36)
    {
    }
    else
    {
      var39 = *((unsigned char *) 0x00001F11);
      if (var39 == 0x00000000)
      {
        *((char *) 0x00001F11) = 0x00000001;
        *((char *) 0x00001F8C) = 0x00000033;
        *((char *) 0x00001F8D) = 0x00000003;
        *((char *) 0x00001F8E) = var38;
        var52 = sceSysconCmdExecAsync (0x00001F80, 0x00000000, 0x0000170C, 0x00000000);
        if (var52 < 0)
        {
          *((char *) 0x00001F11) = 0x00000000;

        label60:
        }
        else
        {
        }
      }
      else
      goto label60;
    }
    var40 = *((int *) 0x00001F04);
    sceKernelSetEventFlag (var40, 0x00000001);
    ra = ((int *) sp)[7];
  }
  var43 = ((int *) sp)[6];
  var44 = ((int *) sp)[5];
  var45 = ((int *) sp)[4];
  var46 = ((int *) sp)[3];
  var47 = ((int *) sp)[2];
  var48 = ((int *) sp)[1];
  var49 = ((int *) sp)[0];
  sp = sp + 0x00000020;
  return;
}

/**
 * Subroutine at address 0x00000880
 */
void sub_00880 (int arg1, int arg2, int arg3)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  var1 = arg1;
  ((int *) sp)[1] = s1;
  var2 = arg3 & 0x000000FF;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  var3 = arg2 & 0x000000FF;
  var6 = sceKernelGetSystemTimeLow ();
  var7 = *((int *) 0x00001FF8);
  var8 = *((int *) 0x00002418);
  var9 = *((int *) 0x00001FF4);
  var10 = var7 + 0x00000001;
  var11 = var10 - (((var10 + ((var10 >> 0x0000001F) >> 0x0000001A)) & 0xFFFFFFC0) | (0x00000000 & 0x0000003F));
  var12 = var6;
  var13 = (var7 << 0x00000004) + 0x00002000;
  var14 = (var8 << 0x00000004) + 0x00002420;
  *((int *) 0x00001FF8) = var11;
  if (var11 == var9)
  {
    var65 = var11 + 0x00000001;
    *((int *) 0x00001FF4) = (var65 - (((var65 + ((var65 >> 0x0000001F) >> 0x0000001A)) & 0xFFFFFFC0) | (0x00000000 & 0x0000003F)));
  }
  var15 = var8 + 0x00000001;
  var16 = *((int *) 0x00002414);
  var17 = var15 - (((var15 + ((var15 >> 0x0000001F) >> 0x0000001A)) & 0xFFFFFFC0) | (0x00000000 & 0x0000003F));
  *((int *) 0x00002418) = var17;
  if (var17 == var16)
  {
    var64 = var17 + 0x00000001;
    *((int *) 0x00002414) = (var64 - (((var64 + ((var64 >> 0x0000001F) >> 0x0000001A)) & 0xFFFFFFC0) | (0x00000000 & 0x0000003F)));
  }
  ((int *) var13)[0] = var12;
  ((int *) var14)[0] = var12;
  var18 = *((int *) 0x00002934);
  if (!(var18 <= 0))
  {
    *((int *) 0x00002934) = (var18 + 0xFFFFFFFF);
    var3 = *((unsigned char *) 0x00002932);
    var2 = *((unsigned char *) 0x00002933);
  }
  ((char *) var13)[8] = var3;
  ((char *) var13)[9] = var2;
  ((char *) var14)[8] = var3;
  ((char *) var14)[9] = var2;
  var19 = *((unsigned char *) 0x00001F0C);
  if (var19 != 0x00000000)
  {
    var20 = *((unsigned char *) 0x00001F0D);
  }
  else
  {
    ((char *) var13)[9] = 0xFFFFFF80;
    ((char *) var13)[8] = 0xFFFFFF80;
    var20 = *((unsigned char *) 0x00001F0D);
  }
  if (!(var20 != 0x00000000))
  {
    ((char *) var14)[9] = 0xFFFFFF80;
    ((char *) var14)[8] = 0xFFFFFF80;
  }
  ((short *) var13)[5] = 0x00000000;
  var21 = var1;
  ((short *) var13)[6] = 0x00000000;
  ((short *) var13)[7] = 0x00000000;
  ((short *) var14)[5] = 0x00000000;
  ((short *) var14)[6] = 0x00000000;
  ((short *) var14)[7] = 0x00000000;
  if (!((var1 & 0x00020000) == 0x00000000))
  {
    var21 = var1 & 0x030E0000;
  }
  var22 = *((int *) 0x0000293C);
  var23 = var21 | var22;
  ((int *) var14)[1] = var23;
  var24 = !var23;
  var25 = *((int *) 0x0000292C);
  var26 = *((int *) 0x00002408);
  var27 = *((int *) 0x00002944);
  var28 = *((int *) 0x0000240C);
  var29 = *((int *) 0x00002400);
  var30 = *((int *) 0x00002404);
  var31 = *((int *) 0x00002410);
  var32 = var25 ^ var23;
  var33 = var1 & var27;
  *((int *) 0x0000292C) = var23;
  *((int *) 0x00002408) = (var26 | var23);
  *((int *) 0x0000240C) = (var28 | var24);
  *((int *) 0x00002400) = (var29 | (var32 & var23));
  *((int *) 0x00002404) = (var30 | (var32 & var24));
  *((int *) 0x00002410) = (var31 + 0x00000001);
  if (!((var33 & 0x00020000) == 0x00000000))
  {
    var33 = var33 & 0x00030000;
  }
  var34 = *((int *) 0x00002938);
  var35 = *((int *) 0x00002940);
  var36 = var33 | var34;
  if (!(var35 <= 0))
  {
    var37 = var35 + 0xFFFFFFFF;
    *((int *) 0x00002940) = var37;
    if (!(var37 != 0x00000000))
    {
      *((int *) 0x0000293C) = 0x00000000;
      *((int *) 0x00002938) = 0x00000000;
    }
  }
  var38 = 0x00002910;
  var39 = 0x0000000F;
  while (1) {
    var40 = ((int *) var38)[0];
    if (var40 == 0x00000000)
    {
      var39 = var39 + 0xFFFFFFFF;
    }
    else
    {
      var41 = ((int *) var38)[1];
      if ((var36 & var40) == var41)
      {
        var57 = ((unsigned char *) var38)[12];
        var58 = var57 >> 0x00000006;
        var59 = ((var57 & 0x0000003F) + 0xFFFFFFFF) & 0x000000FF;
        if (var58 != 0x00000000)
        {
          if (var58 == 0x00000002)
          {
            var63 = ((int *) var38)[2];
            var36 = var36 | var63;
          }
          else
          {
            var62 = ((int *) var38)[2];
            var36 = var36 & (!var62);
          }
          var61 = var58 << 0x00000006;
          if (!(var59 != 0x00000000))
          {
            var60 = var58 ^ 0x00000001;
            var59 = ((unsigned char *) (var38 + (var60 & 0x00000001)))[13];

          label35:
            var61 = var60 << 0x00000006;
          }
        }
        else
        {
          var59 = ((unsigned char *) var38)[15];
          var60 = 0x00000002;
          goto label35;
        }
        ((char *) var38)[12] = (var61 | var59);
      }
      else
      {
        ((char *) var38)[12] = 0x00000000;
      }
      var39 = var39 + 0xFFFFFFFF;
    }
    var38 = var38 + 0xFFFFFFF0;
    if (var39 >= 0)
      continue;
    break;
  }
  var42 = *((int *) 0x00002944);
  var43 = *((int *) 0x00002948);
  var44 = *((int *) 0x00002938);
  var45 = (var36 & var42) | var43;
  if (var44 == 0x00000000)
  {

  label43:
  }
  else
  {
    if (!((var45 & 0x00020000) == 0x00000000))
    {
      var45 = ((var45 & 0x0002F3F9)) ? ((var45 & 0xFFFDFFFF) | (0x00000000 & 0x00000001)) : var45;
      goto label43;
    }
  }
  if ((var45 & 0x00020000) == 0x00000000)
  {
    ((int *) var13)[1] = var45;
  }
  else
  {
    var45 = var45 & 0x00030000;
    ((int *) var13)[1] = var45;
  }
  var46 = !var45;
  var47 = *((int *) 0x00002928);
  var48 = *((int *) 0x00001FE0);
  var49 = *((int *) 0x00001FF0);
  var50 = var47 ^ var45;
  var51 = *((int *) 0x00001FE8);
  var52 = *((int *) 0x00001FEC);
  var53 = *((int *) 0x00001FE4);
  ra = ((int *) sp)[3];
  var54 = ((int *) sp)[2];
  var55 = ((int *) sp)[1];
  var56 = ((int *) sp)[0];
  *((int *) 0x00001FF0) = (var49 + 0x00000001);
  *((int *) 0x00001FE8) = (var51 | var45);
  *((int *) 0x00001FEC) = (var52 | var46);
  *((int *) 0x00001FE0) = (var48 | (var50 & var45));
  *((int *) 0x00001FE4) = (var53 | (var50 & var46));
  *((int *) 0x00002928) = var45;
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000BFC
 */
void sceCtrl_driver_87B0677D (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var1 = 0x80000107;
  ((int *) sp)[2] = ra;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var4 = sceKernelCpuSuspendIntr ();
    var5 = k1;
    k1 = k1 >> 0x00000010;
    var6 = k1 & 0x00000018;
    var7 = ((var6 < 0x00000001)) + 0x00001F00;
    var1 = ((unsigned char *) var7)[12];
    ((char *) var7)[12] = arg1;
    k1 = var5;
    sceKernelCpuResumeIntr (var4);
  }
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000C70
 */
void sceCtrl_driver_6D4BEA72 (int arg1)
{
  var1 = arg1;
  var2 = k1;
  k1 = k1 >> 0x00000010;
  var3 = k1 & 0x00000018;
  if (!(((0x00000000 - var3) & var1) < 0))
  {
    var4 = k1 & 0x00000018;
    var5 = ((unsigned char *) (((var4 < 0x00000001)) + 0x00001F00))[12];
    ((int *) var1)[0] = var5;
  }
  k1 = var2;
  return;
}

/**
 * Subroutine at address 0x00000CB8
 */
void sceCtrl_driver_8AAECD34 (int arg1)
{
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  ((int *) sp)[5] = ra;
  ((int *) sp)[4] = s4;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  var2 = k1;
  k1 = k1 >> 0x00000010;
  var5 = sceKernelCpuSuspendIntr ();
  if (var1 == 0x00000000)
  {
    var6 = *((int *) 0x00001F08);
    *((int *) 0x00001F08) = 0x00000000;
    sceKernelEnableSubIntr (0x0000001E, 0x00000013);
    var27 = *((int *) 0x00001F00);
    SysTimerForKernel_F5A719D1 (var27, 0x00000000, 0x00000000, 0x00000000);
    var30 = *((int *) 0x00001F00);
    SysTimerForKernel_62AB11D2 (var30);
  }
  else
  {
    var6 = 0x800001FE;
    if (!(((var1 < 0x000015B3)) != 0x00000000))
    {
      var6 = 0x800001FE;
      if (((var1 < 0x00004E21)) != 0x00000000)
      {
        var14 = *((int *) 0x00001F00);
        var6 = *((int *) 0x00001F08);
        *((int *) 0x00001F08) = var1;
        SysTimerForKernel_D9A211BC (var14);
        var19 = SysMemForKernel_2CFF6F90 ();
        var20 = *((int *) 0x00001F00);
        SysTimerForKernel_F5A719D1 (var20, (var1 + ((((0x0204FFFF < var19)) < 0x00000001))), 0x000003F0, 0x00000000);
        InterruptManagerForKernel_668A0FF9 (0x0000001E, 0x00000013);
      }
    }
  }
  sceKernelCpuResumeIntr (var5);
  k1 = var2;
  ra = ((int *) sp)[5];
  var9 = ((int *) sp)[4];
  var10 = ((int *) sp)[3];
  var11 = ((int *) sp)[2];
  var12 = ((int *) sp)[1];
  var13 = ((int *) sp)[0];
  sp = sp + 0x00000020;
  return;
}

/**
 * Subroutine at address 0x00000DDC
 */
void sceCtrl_driver_655A18BE (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  var2 = k1;
  k1 = k1 >> 0x00000010;
  var5 = sceKernelCpuSuspendIntr ();
  var6 = k1 & 0x00000018;
  if (((0x00000000 - var6) & var1) < 0)
  {
    sceKernelCpuResumeIntr (var5);
    k1 = var2;
  }
  else
  {
    var7 = k1 & 0x00000018;
    if (var7 == 0x00000000)
    {
      var8 = *((int *) 0x00002400);
      var9 = 0x00002400;
    }
    else
    {
      var8 = *((int *) 0x00001FE0);
      var9 = 0x00001FE0;
    }
    ((int *) var1)[0] = var8;
    var10 = ((int *) var9)[1];
    ((int *) var1)[1] = var10;
    var11 = ((int *) var9)[2];
    ((int *) var1)[2] = var11;
    var12 = ((int *) var9)[3];
    ((int *) var1)[3] = var12;
    var13 = ((int *) var9)[4];
    sceKernelCpuResumeIntr (var5);
    k1 = var2;
  }
  ra = ((int *) sp)[2];
  var16 = ((int *) sp)[1];
  var17 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000E98
 */
void sceCtrl_driver_5068A531 (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  var2 = k1;
  k1 = k1 >> 0x00000010;
  var5 = sceKernelCpuSuspendIntr ();
  var6 = k1 & 0x00000018;
  if (((0x00000000 - var6) & var1) < 0)
  {
    sceKernelCpuResumeIntr (var5);
    k1 = var2;
  }
  else
  {
    var7 = k1 & 0x00000018;
    if (var7 == 0x00000000)
    {
      var17 = *((int *) 0x00002400);
      ((int *) var1)[0] = var17;
      var18 = *((int *) 0x00002404);
      ((int *) var1)[1] = var18;
      var19 = *((int *) 0x00002408);
      ((int *) var1)[2] = var19;
      var20 = *((int *) 0x0000240C);
      ((int *) var1)[3] = var20;
      *((int *) 0x00002400) = 0x00000000;
      *((int *) 0x00002404) = 0x00000000;
      *((int *) 0x00002408) = 0x00000000;
      *((int *) 0x0000240C) = 0x00000000;
      var12 = *((int *) 0x00002410);
      *((int *) 0x00002410) = 0x00000000;
    }
    else
    {
      var8 = *((int *) 0x00001FE0);
      ((int *) var1)[0] = var8;
      var9 = *((int *) 0x00001FE4);
      ((int *) var1)[1] = var9;
      var10 = *((int *) 0x00001FE8);
      ((int *) var1)[2] = var10;
      var11 = *((int *) 0x00001FEC);
      ((int *) var1)[3] = var11;
      var12 = *((int *) 0x00001FF0);
      *((int *) 0x00001FE0) = 0x00000000;
      *((int *) 0x00001FF0) = 0x00000000;
      *((int *) 0x00001FE4) = 0x00000000;
      *((int *) 0x00001FE8) = 0x00000000;
      *((int *) 0x00001FEC) = 0x00000000;
    }
    sceKernelCpuResumeIntr (var5);
    k1 = var2;
  }
  ra = ((int *) sp)[2];
  var15 = ((int *) sp)[1];
  var16 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000FA4
 */
void sceCtrl_driver_67B648BD (int arg1, int arg2, int arg3, int arg4)
{
  if (!(arg1 == 0x00000000))
  {
    var1 = *((int *) 0x00002950);
    ((int *) arg1)[0] = var1;
  }
  if (!(arg2 == 0x00000000))
  {
    var2 = *((int *) 0x00002954);
    ((int *) arg2)[0] = var2;
  }
  if (!(arg3 == 0x00000000))
  {
    var3 = *((int *) 0x00002958);
    ((int *) arg3)[0] = var3;
  }
  if (!(arg4 == 0x00000000))
  {
    var4 = *((int *) 0x0000295C);
    ((int *) arg4)[0] = var4;
  }
  return;
}

/**
 * Subroutine at address 0x00000FEC
 */
void sceCtrl_driver_03A81798 (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = arg1;
  ((int *) sp)[0] = s0;
  var2 = arg2;
  var3 = 0x800001FE;
  ((int *) sp)[2] = ra;
  if (!((((((arg1 + 0x00000001) < 0x00000082)) ^ 0x00000001) | ((arg2 < 0xFFFFFFFF))) != 0x00000000))
  {
    if (!(((var2 < 0x00000081)) == 0x00000000))
    {
      var6 = sceKernelCpuSuspendIntr ();
      *((int *) 0x00002964) = (!((!var2)) ? 0x00000081 : var2);
      *((int *) 0x00002960) = (!((!var1)) ? 0x00000081 : var1);
      sceKernelCpuResumeIntr (var6);
      var3 = 0x00000000;
    }
  }
  ra = ((int *) sp)[2];
  var9 = ((int *) sp)[1];
  var10 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00001078
 */
void sceCtrl_driver_E3F78BF9 (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  var1 = arg2;
  ((int *) sp)[0] = s0;
  var2 = arg1;
  ((int *) sp)[3] = ra;
  ((int *) sp)[1] = s1;
  var3 = k1;
  k1 = k1 >> 0x00000010;
  var4 = k1 & 0x00000018;
  if (((0x00000000 - var4) & var2) < 0)
  {

  label17:
    k1 = var3;
  }
  else
  {
    var5 = k1 & 0x00000018;
    if (!(((0x00000000 - var5) & arg2) >= 0))
      goto label17;
    var11 = sceKernelCpuSuspendIntr ();
    if (!(var2 == 0x00000000))
    {
      var12 = *((int *) 0x00002960);
      if (var12 == 0x00000081)
      {
        var12 = 0xFFFFFFFF;
      }
      ((int *) var2)[0] = var12;
    }
    if (!(var1 == 0x00000000))
    {
      var13 = *((int *) 0x00002964);
      if (var13 == 0x00000081)
      {
        var13 = 0xFFFFFFFF;
      }
      ((int *) var1)[0] = var13;
    }
    sceKernelCpuResumeIntr (var11);
    k1 = var3;
  }
  ra = ((int *) sp)[3];
  var6 = ((int *) sp)[2];
  var7 = ((int *) sp)[1];
  var8 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00001140
 */
void sceCtrl_driver_C24FF87A (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  var1 = 0x00000001;
  ((int *) sp)[1] = s1;
  var2 = arg2;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  var3 = arg1;
  var6 = sceKernelCpuSuspendIntr ();
  var7 = *((int *) 0x00002944);
  var8 = *((int *) 0x00002948);
  if (!((var7 & var3) == 0x00000000))
  {
    var1 = !((var8 & var3)) ? 0x00000000 : 0x00000002;
  }
  if (var2 != 0x00000000)
  {
    var14 = !var3;
    if (var2 == 0x00000001)
    {
      var8 = var8 & var14;
      var7 = var7 & var14;

    label14:
    }
    else
    {
      if (!(var2 != 0x00000002))
      {
        var8 = var8 | var3;

      label13:
        var7 = var7 | var3;
        goto label14;
      }
    }
  }
  else
  {
    var8 = var8 & (!var3);
    goto label13;
  }
  *((int *) 0x00002948) = var8;
  *((int *) 0x00002944) = var7;
  sceKernelCpuResumeIntr (var6);
  ra = ((int *) sp)[3];
  var11 = ((int *) sp)[2];
  var12 = ((int *) sp)[1];
  var13 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000011F4
 */
void sceCtrl_driver_09236627 (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = 0x00000001;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  var2 = arg1;
  var5 = sceKernelCpuSuspendIntr ();
  var6 = *((int *) 0x00002944);
  var7 = *((int *) 0x00002948);
  if (!((var6 & var2) == 0x00000000))
  {
    var1 = !((var7 & var2)) ? 0x00000000 : 0x00000002;
  }
  sceKernelCpuResumeIntr (var5);
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00001258
 */
void sceCtrl_driver_F83A8920 (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
{
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[5] = s5;
  ((int *) sp)[6] = s6;
  ((int *) sp)[4] = s4;
  ((int *) sp)[7] = s7;
  ((int *) sp)[3] = s3;
  var1 = 0x80000102;
  ((int *) sp)[2] = s2;
  var2 = arg3;
  ((int *) sp)[1] = s1;
  var3 = arg2;
  ((int *) sp)[8] = ra;
  ((int *) sp)[0] = s0;
  if (!(((arg1 < 0x00000010)) == 0x00000000))
  {
    var1 = 0x800001FE;
    if (!((((((arg5 | arg6) | arg7) + 0xFFFFFFFF) < 0x0000003F)) == 0x00000000))
    {
      var4 = k1;
      k1 = k1 >> 0x00000010;
      var5 = k1 & 0x00000018;
      if (var5 == 0x00000000)
      {

      label7:
        var8 = sceKernelCpuSuspendIntr ();
        var9 = (arg1 << 0x00000004) + 0x00001F00;
        var10 = var9 + 0x00000920;
        ((char *) var10)[13] = arg6;
        ((char *) var9)[2351] = arg5;
        ((int *) var9)[584] = var3;
        ((int *) var9)[585] = var2;
        ((int *) var9)[586] = arg4;
        ((char *) var9)[2350] = arg7;
        ((char *) var10)[12] = 0x00000000;
        sceKernelCpuResumeIntr (var8);
        k1 = var4;
        var1 = 0x00000000;
      }
      else
      {
        if (!((((var3 | var2) | arg4) & 0xFFFF0C06) != 0x00000000))
          goto label7;
        k1 = var4;
        var1 = 0x80000023;
      }
    }
  }
  ra = ((int *) sp)[8];
  var13 = ((int *) sp)[7];
  var14 = ((int *) sp)[6];
  var15 = ((int *) sp)[5];
  var16 = ((int *) sp)[4];
  var17 = ((int *) sp)[3];
  var18 = ((int *) sp)[2];
  var19 = ((int *) sp)[1];
  var20 = ((int *) sp)[0];
  sp = sp + 0x00000030;
  return;
}

/**
 * Subroutine at address 0x0000137C
 */
void module_start ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sceCtrl_driver_45F1294D ();
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x0000139C
 */
void module_reboot_before ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sceCtrl_driver_A6CF75FE ();
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000013BC
 */
void sceCtrl_driver_0194C9EC ()
{
  var1 = *((int *) 0x00001F08);
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  if (var1 != 0x00000000)
  {
    var4 = *((int *) 0x00001F00);
    SysTimerForKernel_62AB11D2 (var4);
    ra = ((int *) sp)[0];
  }
  else
  {
    InterruptManagerForKernel_668A0FF9 (0x0000001E, 0x00000013);
    ra = ((int *) sp)[0];
  }
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00001404
 */
void sceCtrl_driver_33893636 ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var1 = *((int *) 0x00001F08);
  ((int *) sp)[2] = ra;
  *((char *) 0x00001F0F) = 0xFFFFFFFF;
  if (var1 != 0x00000000)
  {
    var6 = *((int *) 0x00001F00);
    SysTimerForKernel_D9A211BC (var6);
    var9 = *((int *) 0x00001F00);
    var10 = *((int *) 0x00001F08);
    SysTimerForKernel_F5A719D1 (var9, var10, 0x000003F0, 0x00000000);
    ra = ((int *) sp)[2];
  }
  else
  {
    sceKernelEnableSubIntr (0x0000001E, 0x00000013);
    ra = ((int *) sp)[2];
  }
  var4 = ((int *) sp)[1];
  var5 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x0000147C
 */
void sceCtrl_driver_A0390EE8 (int arg1)
{
  var1 = k1;
  k1 = k1 >> 0x00000010;
  var2 = k1 & 0x00000018;
  if (!(((0x00000000 - var2) & arg1) < 0))
  {
    var3 = *((int *) 0x00001F08);
    ((int *) arg1)[0] = var3;
  }
  k1 = var1;
  return;
}

/**
 * Subroutine at address 0x000014AC
 */
void sceCtrl_driver_6B247CCE (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sub_01730 (arg1, arg2, 0x00000000);
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000014C8
 */
void sceCtrl_driver_CC2D8C39 (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sub_01730 (arg1, arg2, 0x00000001);
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000014E4
 */
void sceCtrl_driver_919215D7 (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sub_01730 (arg1, arg2, 0x00000002);
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00001500
 */
void sceCtrl_driver_F54317C4 (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sub_01730 (arg1, arg2, 0x00000003);
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x0000151C
 */
void sceCtrl_driver_0A218F56 (int arg1, int arg2, int arg3, int arg4)
{
  *((int *) 0x0000295C) = arg4;
  *((int *) 0x00002950) = arg1;
  *((int *) 0x00002954) = arg2;
  *((int *) 0x00002958) = arg3;
  return;
}

/**
 * Subroutine at address 0x0000153C
 */
void sceCtrl_driver_7EBC7B38 (int arg1)
{
  *((int *) 0x00001F14) = arg1;
  return;
}

/**
 * Subroutine at address 0x0000154C
 */
void sceCtrl_driver_189BA4F3 (int arg1)
{
  if (!(((arg1 < 0x0000012D)) == 0x00000000))
  {
    *((int *) 0x00001F1C) = (!((arg1 ^ 0x00000001)) ? 0x00000000 : arg1);
  }
  return;
}

/**
 * Subroutine at address 0x00001578
 */
void sceCtrl_driver_46C2F764 ()
{
  var1 = *((int *) 0x00001F1C);
  return;
}

/**
 * Subroutine at address 0x00001584
 */
void sceCtrl_driver_B5507BFA (int arg1, int arg2, int arg3)
{
  *((int *) 0x00002940) = arg3;
  *((int *) 0x00002938) = arg1;
  *((int *) 0x0000293C) = arg2;
  return;
}

/**
 * Subroutine at address 0x000015A0
 */
void sceCtrl_driver_81276F4B (int arg1, int arg2, int arg3)
{
  *((int *) 0x00002934) = arg3;
  *((char *) 0x00002932) = arg1;
  *((char *) 0x00002933) = arg2;
  return;
}

/**
 * Subroutine at address 0x000015BC
 */
void sceCtrl_driver_2037F8E7 (int arg1, int arg2, int arg3, int arg4)
{
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = s3;
  var1 = 0x80000102;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[4] = ra;
  if (!(((arg1 < 0x00000004)) == 0x00000000))
  {
    var4 = sceKernelCpuSuspendIntr ();
    var5 = (arg1 << 0x00000004) + 0x00001F00;
    ((int *) var5)[666] = arg2;
    ((int *) var5)[667] = arg3;
    var6 = gp;
    ((int *) var5)[669] = arg4;
    ((int *) var5)[668] = var6;
    sceKernelCpuResumeIntr (var4);
    var1 = 0x00000000;
  }
  ra = ((int *) sp)[4];
  var9 = ((int *) sp)[3];
  var10 = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x00000020;
  return;
}

/**
 * Subroutine at address 0x0000164C
 */
void sceCtrl_driver_2393D6F3 ()
{
  *((char *) 0x00001F0E) = 0x00000001;
  return;
}

/**
 * Subroutine at address 0x00001660
 */
void sceCtrl_driver_F17D609C (int arg1)
{
  if (!(((arg1 < 0x00000010)) == 0x00000000))
  {
    ((int *) ((arg1 << 0x00000004) + 0x00001F00))[584] = 0x00000000;
  }
  return;
}

/**
 * Subroutine at address 0x00001690
 */
void sub_01690 ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[2] = ra;
  var3 = sceKernelCpuSuspendIntr ();
  var4 = *((int *) 0x00001F18);
  if (var4 != 0x00000000)
  {
    var6 = *((int *) 0x00002920);
  }
  else
  {
    var5 = *((int *) 0x00002920);
    var6 = var5 & 0xFFFF0C06;
  }
  var7 = *((unsigned char *) 0x00002931);
  var8 = *((unsigned char *) 0x00002930);
  sub_00880 (var6, var8, var7);
  var11 = *((int *) 0x00001F04);
  sceKernelSetEventFlag (var11, 0x00000001);
  sceKernelCpuResumeIntr (var3);
  ra = ((int *) sp)[2];
  var16 = ((int *) sp)[1];
  var17 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x0000170C
 */
void sub_0170C ()
{
  var1 = *((unsigned char *) 0x00001F8E);
  *((char *) 0x00001F0E) = 0x00000000;
  *((char *) 0x00001F0F) = (var1 & 0x00000001);
  *((char *) 0x00001F11) = 0x00000000;
  return;
}

/**
 * Subroutine at address 0x00001730
 */
void sub_01730 (int arg1, int arg2, int arg3)
{
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[1] = s1;
  var1 = arg2;
  ((int *) sp)[5] = s5;
  var2 = 0x80000104;
  ((int *) sp)[4] = s4;
  var3 = arg3;
  ((int *) sp)[7] = ra;
  ((int *) sp)[6] = s6;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[0] = s0;
  if (!((((arg2 + 0xFFFFFFFF) < 0x00000040)) == 0x00000000))
  {
    var4 = k1;
    k1 = k1 >> 0x00000010;
    var5 = k1 & 0x00000018;
    if (((0x00000000 - var5) & arg1) < 0)
    {
      k1 = var4;
      var2 = 0x80000023;
    }
    else
    {
      var6 = k1 & 0x00000018;
      var7 = 0x00001FE0;
      if (!(var6 != 0x00000000))
      {
        var7 = 0x00002400;
      }
      if ((var3 & 0x00000002) == 0x00000000)
      {
        var22 = 0x00000040;
        var42 = sceKernelCpuSuspendIntr ();
        var43 = ((int *) var7)[6];
        var16 = var42;
        var20 = var43;
        if (!(((var1 < 0x00000040)) == 0x00000000))
        {
          var23 = var43 - var1;

        label22:
          var20 = (((var23 < 0x00000000))) ? (var23 + 0x00000040) : var23;
          var22 = var1;
        }

      label23:
        var24 = (var7 + (var20 << 0x00000004)) + 0x00000020;
        if (!(var22 <= 0))
        {
          var25 = arg1;
          var26 = var22;
          var27 = ((int *) var24)[0];
          while (1) {
            var20 = var20 + 0x00000001;
            var26 = var26 + 0xFFFFFFFF;
            ((int *) var25)[0] = var27;
            var28 = ((int *) var24)[1];
            ((int *) var25)[1] = var28;
            var29 = ((int *) var24)[2];
            ((int *) var25)[2] = var29;
            var30 = ((int *) var24)[3];
            ((int *) var25)[1] = (((var3 & 0x00000001)) ? (!var28) : var28);
            var24 = var24 + 0x00000010;
            ((int *) var25)[3] = var30;
            var25 = var25 + 0x00000010;
            if (var20 == 0x00000040)
            {
              var20 = 0x00000000;
              var24 = var7 + 0x00000020;
            }
            if (!(var26 != 0x00000000))
              break;
            var27 = ((int *) var24)[0];
            continue;
          }
        }
        sceKernelCpuResumeIntr (var16);
        k1 = var4;
        var2 = var22;
      }
      else
      {
        var8 = *((int *) 0x00001F04);
        var11 = sceKernelWaitEventFlag (var8, 0x00000001, 0x00000001, 0x00000000, 0x00000000);
        if (var11 < 0)
        {
          k1 = var4;
          var2 = var11;
        }
        else
        {
          var14 = sceKernelCpuSuspendIntr ();
          var15 = *((int *) 0x00001F04);
          var16 = var14;
          sceKernelClearEventFlag (var15, 0xFFFFFFFE);
          var19 = ((int *) var7)[6];
          var20 = ((int *) var7)[5];
          var21 = var19 - var20;
          var22 = (((var21 < 0x00000000))) ? (var21 + 0x00000040) : var21;
          ((int *) var7)[5] = var19;
          if (!(((var1 < var22)) == 0x00000000))
          {
            var23 = var19 - var1;
            goto label22;
          }
          goto label23;
        }
      }
    }
  }
  ra = ((int *) sp)[7];
  var33 = ((int *) sp)[6];
  var34 = ((int *) sp)[5];
  var35 = ((int *) sp)[4];
  var36 = ((int *) sp)[3];
  var37 = ((int *) sp)[2];
  var38 = ((int *) sp)[1];
  var39 = ((int *) sp)[0];
  sp = sp + 0x00000020;
  return;
}

